<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );

// ------------------  standard plugin initialize function - don't change ---------------------------
global $sh_LANG;
$sefConfig = & shRouter::shGetConfig();  
$shLangName = '';
$shLangIso = '';
$title = array();
$shItemidString = '';
$dosef = shInitializePlugin( $lang, $shLangName, $shLangIso, $option);
if ($dosef == false) return;

// Redefine function
if( ! function_exists('shRemoveFromGETVarsList_JobBoard') ){
	function shRemoveFromGETVarsList_JobBoard( $paramName) {
	  global $shGETVars, $shRebuildNonSef;
	
	  $sefConfig = shRouter::shGetConfig();
	  if (!$sefConfig->shAppendRemainingGETVars) return null;
	  if (!empty($paramName)) {
	    if (isset($shGETVars[$paramName])) {
	      $shValue = $shGETVars[$paramName];
	      if( is_array($shValue) ){
	      	foreach ($shValue as $value){
	      		$shRebuildNonSef[] = '&'.$paramName.'[]='.$value;
	      	}	      	
	      }else{
	      	$shRebuildNonSef[] = '&'.$paramName.'='.$shValue;
	      }  // build up a non-sef string with the GET vars used to
	      // build the SEF string. This string will be the one stored in db instead of
	      // the full, original one
	      unset( $shGETVars[@$paramName]);
	    }
	  }
	}
}

// ------------------  standard plugin initialize function - don't change ---------------------------

// ------------------  load language file - adjust as needed ----------------------------------------
	
// ------------------  load language file - adjust as needed ----------------------------------------                                           

$Itemid = isset($Itemid) ? @$Itemid : null;   
// do something about that Itemid thing  V 1.2.4.m
if (!preg_match( '/Itemid=[0-9]+/i', $string)) { // if no Itemid in non-sef URL
//if (eregi('Itemid=[0-9]+', $string) === false) { // if no Itemid in non-sef URL
  if ($sefConfig->shInsertGlobalItemidIfNone && !empty($shCurrentItemid)) {
    $string .= '&Itemid='.$shCurrentItemid;  // append current Itemid
    $Itemid = $shCurrentItemid; 
    shRemoveFromGETVarsList('Itemid', $Itemid);
  }  
  if ($sefConfig->shInsertTitleIfNoItemid) {
  	$title[] = $shCBName;
  	// prevent from adding another time
  	$sefConfig->shInsertCBName = false;
  }	
  $shItemidString = '';
  if ($sefConfig->shAlwaysInsertItemid && (!empty($Itemid) || !empty($shCurrentItemid)))
    $shItemidString = COM_SH404SEF_ALWAYS_INSERT_ITEMID_PREFIX.$sefConfig->replacement
        .(empty($Itemid)? $shCurrentItemid :$Itemid);
} else {  // if Itemid in non-sef URL
  $shItemidString = $sefConfig->shAlwaysInsertItemid ? 
    COM_SH404SEF_ALWAYS_INSERT_ITEMID_PREFIX.$sefConfig->replacement.$Itemid
    : '';
  if ($sefConfig->shAlwaysInsertMenuTitle){
    //global $Itemid; V 1.2.4.g we want the string option, not current page !
    $title[] = $shCBName;
    // prevent from adding another time
  	$sefConfig->shInsertCBName = false;  
  }  
} 

if (!empty($Itemid))
  shRemoveFromGETVarsList('Itemid');  

	// Options
	if ( isset($option) ){
		$title[] = "jobs";
		shRemoveFromGETVarsList('option');
	}	
	shRemoveFromGETVarsList('lang');
	
	// optional removal of limit and limitstart
	if (!empty($limit))                       // use empty to test $limit as $limit is not allowed to be zero
		shRemoveFromGETVarsList('limit');
	if (isset($limitstart))                   // use isset to test $limitstart, as it can be zero
		shRemoveFromGETVarsList('limitstart');  
	
	// View
	if ( isset($view)){
		if($view != "jajobs")
			$title[] = str_replace("ja", "", $view);
		shRemoveFromGETVarsList('view');
	}	
	// Layout
	if ( isset($layout) ){
		$title[] = str_replace("ja", "", $layout);
		shRemoveFromGETVarsList('layout');
	}
	// Cid
	/*if ( isset($cid)){
		$strings = $cid[0];
		if ( isset($alias) ){
			$strings .= "-".$alias;
			shRemoveFromGETVarsList('alias');
		}
		$title[] = $strings;
		
		shRemoveFromGETVarsList_JobBoard('cid');
	}*/
	if ( isset($alias) ){
		$title[] = $alias;
		shRemoveFromGETVarsList('alias');
	}
		
	// profile_id
	if ( isset($profile_id) ){
		$title[] = $profile_id;
		shRemoveFromGETVarsList('profile_id');
	}
	// uid
	if ( isset($uid) ){
		$title[] = $uid;
		shRemoveFromGETVarsList('uid');
	}
// ------------------  standard plugin finalize function - don't change ---------------------------  
if ($dosef){
   $string = shFinalizePlugin( $string, $title, $shAppendString, $shItemidString, 
      (isset($limit) ? @$limit : null), (isset($limitstart) ? @$limitstart : null), 
      (isset($shLangName) ? @$shLangName : null));
}      
// ------------------  standard plugin finalize function - don't change ---------------------------
  
?>